<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('外部联系人列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
         <!--   <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>请假名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>-->

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addTab()()" shiro:hasPermission="system:extContactUser:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:extContactUser:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" data-show-print="true" data-print-as-filtered-and-sorted-on-ui="true"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: bootstrap-table-print-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:extContactUser:edit')}]];
        var detailFlag = [[${@permission.hasPermi('system:extContactUser:detail')}]];
        var removeFlag = [[${@permission.hasPermi('system:extContactUser:remove')}]];
        var prefix = ctx + "ding/extContactUser";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                detailUrl:prefix + "/detail/{id}",
                printPageBuilder: printPageBuilder,
                modalName: "外部联系人",
                columns: [{
                    checkbox: true,
                    printIgnore: true
                },
                {
                    field: 'userid',
                    title: '用户id',
                    visible: false,
                    printIgnore: true
                },
                {
                    field: 'name',
                    title: '用户名称'
                },
                {
                    field: 'mobile',
                    title: '电话'
                },
                {
                    field: 'companyName',
                    title: '所属公司'
                },
                {
                    field: 'title',
                    title: '职位'
                 },
                {
                    title: '操作',
                    align: 'center',
                    printIgnore: true,
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.userid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.userid + '\')"><i class="fa fa-search-plus"></i>详情</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.userid + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        // 自定义打印页面模板
        function printPageBuilder(table) {
            return `
        	<html>
        	  <head>
        	  <style type="text/css" media="print">
        	  @page {
        	    size: auto;
        	    margin: 25px 0 25px 0;
        	  }
        	  </style>
        	  <style type="text/css" media="all">
        	  table {
        	    border-collapse: collapse;
        	    font-size: 12px;
        	  }
        	  table, th, td {
        	    border: 1px solid grey;
        	  }
        	  th, td {
        	    text-align: center;
        	    vertical-align: middle;
        	  }
        	  p {
        	    font-weight: bold;
        	    margin-left:20px;
        	  }
        	  table {
        	    width:95%;
        	    margin-left:3%;
        	    margin-right:3%;
        	  }
        	  div.bs-table-print {
        	    text-align:center;
        	  }
        	  </style>
        	  </head>
        	  <title>打印外部联系人</title>

        	  <body>
        	  <h1 style="text-align:center">打印外部联系人 </h1>
        	  <div class="bs-table-print">${table}</div>
        	  </body>
        	</html>`
        }
    </script>
</body>
</html>